<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .outBox{
            width: 500px;
            height: 500px;
            overflow-y: scroll;
        }
        .innerBox{
            width: 500px;
            height: 2000px;
            background-color: aqua;
        }
    </style>
</head>
<body>
    <div class="outBox" id="box">
        <div class="innerBox"></div>
    </div>
</body>
<script>
    document.getElementById("box").addEventListener("scroll",function(){
        // console.log("滚动了");
        //可以滚动的高度
        let scrollHeight = box.scrollHeight;
        console.log("可以滚动的高度：",scrollHeight);
        //向上滚走的距离
        let scrollTop = box.scrollTop;
        console.log("滚走的距离：",scrollTop);
        //窗口的高度
        let clientHeight = box.clientHeight;
        console.log("窗口的高度：",clientHeight);
    
        console.log(scrollHeight-scrollTop-clientHeight<1?"触底了":"");
    })
</script>
</html>